import request from '@/utils/request'
export function uploadImg(data) {
  return request({
    url: 'system/oss/upload',
    method: 'post',
    data
  })
}

export function createCURD(moduleName) {
  return {
    /**
     * 列表
     * @param {*} param
     */
    list(param) {
      const { pageNum, pageSize, ...data } = param
      return request({
        url: `/gongyuan/${moduleName}/list?pageNum=${pageNum}&pageSize=${pageSize}`,
        method: 'post',
        data
      })
    },
    /**
     * 根据ID查询
     * @param {*} id
     */
    detail(id) {
      return request({
        url: `gongyuan/${moduleName}/${id}`,
        method: 'get'
      })
    },
    /**
     * 删除
     * @param {*} id
     */
    del(id) {
      return request({
        url: `gongyuan/${moduleName}/${id}`,
        method: 'delete'
      })
    },

    /**
     * 添加
     * @param {*} data
     */
    add(data) {
      return request({
        url: `/gongyuan/${moduleName}`,
        method: 'post',
        data
      })
    },

    /**
     * 更新
     * @param {*} data
     */
    update(data) {
      return request({
        url: `/gongyuan/${moduleName}`,
        method: 'put',
        data
      })
    }
  }
}
